package com.glor.operation.common.user.service.impl;

import com.glor.operation.common.user.dto.UserDTO;
import com.glor.operation.common.user.entity.UserEntity;
import com.glor.operation.common.user.repo.UserRepository;
import com.glor.operation.common.user.service.UserService;
import com.glor.operation.common.utils.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created by heylear.cai on 2016/2/18.
 */
@Service
public class UserServiceImpl implements UserService {

    @Autowired
    UserRepository userRepository;

    @Override
    public UserDTO findUserByUsername(String username) {
        UserEntity userEntity = userRepository.findUserByUsername(username);
        if (userEntity != null)
            return BeanUtils.copy(userEntity, UserDTO.class);
        return null;
    }
}
